package com.jwm.power.repository;

import com.jwm.power.model.entity.Menus;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
public interface MenusRepository extends JpaRepository<Menus, Integer>, JpaSpecificationExecutor<Menus> {
    //  获取最大编码
    @Query(value = "select top 1 RIGHT(MenuCode,2) from Menus where ParentCode=?1 order by MenuCode DESC ", nativeQuery = true)
    String getMaxCode(String parentCode);
    //  获取最大序号
    @Query(value = "select top 1 orderbyid from Menus where ParentCode=?1 order by orderbyid DESC ", nativeQuery = true)
    String getMaxSn(String parentCode);

    Menus findByMenucode(@Param("menucode") String menucode);
}
